package demo.IOinterface.Java147_157;

import java.util.Scanner;

public class Windows_login3 {
    public static void main(String[] args) {
        System.out.println("欢迎使用Windows操作系统！");
        for (int i = 1; i <= 3; i++) {
            System.out.println("请输入用户名:");
            String username = new Scanner(System.in).nextLine();
            if (username.equalsIgnoreCase("root")) {
                System.out.print("请输入密码：");
                for(int j= 1; j<= 3; j++){
                    String password = new Scanner(System.in).nextLine();
                    if (password.equals("123")) {
                        System.out.print("登陆成功！");
                    } else {
                        System.out.print("请重新检查密码！"+"剩余次数： " + (3 - i) + "次！");
                    }
                }

            } else {
                if (i == 3) {
                    System.out.println("登陆失败！系统已锁定并退出！");
                    break;
                } else {
                    System.out.println("请重新检查用户名！剩余次数： " + (3 - i) + "次！");
                }
            }

        }
    }
}
